package com.dq.spring.entity;

public class Emp {
	private int empno;
	private String ename;
	private int deptno;
	private int tel;
	
	//private String dname;//部门名称
	//如果实体类中的对象中的属性特别多，显然这个方法不可行。
	
	private Dept dept;//那么此时我们可以直接将这个对象包含进来
	
	

	public Emp(int empno, String ename, int deptno, int tel, Dept dept) {
		super();
		this.empno = empno;
		this.ename = ename;
		this.deptno = deptno;
		this.tel = tel;
		this.dept = dept;
	}

	public int getEmpno() {
		return empno;
	}

	public void setEmpno(int empno) {
		this.empno = empno;
	}

	public int getEmp() {
		return empno;
	}

	public void setEmp(int emp) {
		this.empno = emp;
	}

	public String getEname() {
		return ename;
	}

	public void setEname(String ename) {
		this.ename = ename;
	}

	public int getDeptno() {
		return deptno;
	}

	public void setDeptno(int deptno) {
		this.deptno = deptno;
	}

	public int getTel() {
		return tel;
	}

	public void setTel(int tel) {
		this.tel = tel;
	}

	public Dept getDept() {
		return dept;
	}

	public void setDept(Dept dept) {
		this.dept = dept;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((dept == null) ? 0 : dept.hashCode());
		result = prime * result + deptno;
		result = prime * result + empno;
		result = prime * result + ((ename == null) ? 0 : ename.hashCode());
		result = prime * result + tel;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Emp other = (Emp) obj;
		if (dept == null) {
			if (other.dept != null)
				return false;
		} else if (!dept.equals(other.dept))
			return false;
		if (deptno != other.deptno)
			return false;
		if (empno != other.empno)
			return false;
		if (ename == null) {
			if (other.ename != null)
				return false;
		} else if (!ename.equals(other.ename))
			return false;
		if (tel != other.tel)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Emp [empno=" + empno + ", ename=" + ename + ", deptno=" + deptno + ", tel=" + tel + ", dept=" + dept
				+ "]";
	}

	public Emp(int emp, String ename, int deptno, int tel, String dname, Dept dept) {
		super();
		this.empno = emp;
		this.ename = ename;
		this.deptno = deptno;
		this.tel = tel;
		this.dept = dept;
	}

	public Emp() {
		super();
		// TODO Auto-generated constructor stub
	}
	
}
